<?php

/**
 * This is the model class for table "operating_feature".
 *
 * The followings are the available columns in table 'operating_feature':
 * @property integer $id
 * @property integer $first_brigade_organization
 * @property integer $fire_safety_seminar
 * @property integer $employee_trained_in_emergency_procedure
 * @property integer $fire_or_evacuation_drill
 * @property string $first
 * @property string $second
 * @property string $third
 * @property string $fourth
 * @property string $date_last_conducted
 * @property integer $inspection_id
 *
 * The followings are the available model relations:
 * @property Inspection $inspection
 */
class OperatingFeature extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return OperatingFeature the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'operating_feature';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('inspection_id', 'required'),
			array('first_brigade_organization, fire_safety_seminar, employee_trained_in_emergency_procedure, fire_or_evacuation_drill, inspection_id', 'numerical', 'integerOnly'=>true),
			array('first, second, third, fourth, date_last_conducted', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, first_brigade_organization, fire_safety_seminar, employee_trained_in_emergency_procedure, fire_or_evacuation_drill, first, second, third, fourth, date_last_conducted, inspection_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'inspection' => array(self::BELONGS_TO, 'Inspection', 'inspection_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'first_brigade_organization' => 'First Brigade Organization',
			'fire_safety_seminar' => 'Fire Safety Seminar',
			'employee_trained_in_emergency_procedure' => 'Employee Trained In Emergency Procedure',
			'fire_or_evacuation_drill' => 'Fire Or Evacuation Drill',
			'first' => 'First',
			'second' => 'Second',
			'third' => 'Third',
			'fourth' => 'Fourth',
			'date_last_conducted' => 'Date Last Conducted',
			'inspection_id' => 'Inspection',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('first_brigade_organization',$this->first_brigade_organization);
		$criteria->compare('fire_safety_seminar',$this->fire_safety_seminar);
		$criteria->compare('employee_trained_in_emergency_procedure',$this->employee_trained_in_emergency_procedure);
		$criteria->compare('fire_or_evacuation_drill',$this->fire_or_evacuation_drill);
		$criteria->compare('first',$this->first,true);
		$criteria->compare('second',$this->second,true);
		$criteria->compare('third',$this->third,true);
		$criteria->compare('fourth',$this->fourth,true);
		$criteria->compare('date_last_conducted',$this->date_last_conducted,true);
		$criteria->compare('inspection_id',$this->inspection_id);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}